package com.hutao.manage.controller;

import java.util.Date;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hutao.manage.service.BloodTypeService;
import com.hutao.manage.service.SyncDataService;
import com.hutao.manage.service.SyncHisDataService;
import com.hutao.manage.util.DateUtil;

@Controller
@RequestMapping("/sync")
public class SyncDataController {
	
	
	
	@Autowired
	private BloodTypeService bloodTypeService;
	
	@Autowired
	private SyncDataService syncDataService;
	
	@Autowired
	private SyncHisDataService syncHisDataService;
	
	@ResponseBody
	@RequestMapping("/syncOperation")
	public Map<String,Object> syncOperation(){
		//return syncDataService.syncOps();
		return null;
	}
	
	
	@ResponseBody
	@RequestMapping("/syncDisease")
	public Map<String,Object> syncDisease(){
		//return syncDataService.syncDisease();
		return null;
	}
	
	@ResponseBody
	@RequestMapping("/syncHospitalMan")
	public Map<String,Object> syncHospitalMan(){
		return syncDataService.syncHospitalMan();
	}
	
	@ResponseBody
	@RequestMapping("/syncOffice")
	public Map<String,Object> syncOffice(){
		//根据科室名称更新hisid
		//return syncDataService.syncOfficeByName();
		//根据switch_code_b更新
		//return syncDataService.syncOfficeBySwitchCodeb();
		return null;
	}
	
	@ResponseBody
	@RequestMapping("/addOperativeUser")
	public String addOperativeUser() {
		
		return syncDataService.syncDataService();
		//return null;
	}
	
	
	
	@ResponseBody
	@RequestMapping("/addStdPracticingDoctor")
	public String addStdPracticingDoctor() {
		
		//return syncDataService.addStdPracticingDoctor();
		return null;
	}
	
	
	@ResponseBody
	@RequestMapping("/addStdOperation")
	public String addStdOperation() {
		
		//return syncDataService.addStdOperation();
		return null;
	}
	
	
	@ResponseBody
	@RequestMapping("/addStdDrgChsExclude")
	public String addStdDrgChsExclude() {
		
		//return syncDataService.addStdDrgChsExclude();
		return null;
	}
	
	
	@ResponseBody
	@RequestMapping("/addMrInMedicareByExcel")
	public String addMrInMedicareByExcel() {
		
		//return syncDataService.addMrInMedicareByExcel();
		return null;
	}
	
	
	@ResponseBody
	@RequestMapping("/updateHospiotalManOpscode")
	public String updateHospiotalManOpscode() {
		
		//return syncDataService.updateHospiotalManOpscode();
		return null;
	}
	
	
	@ResponseBody
	@RequestMapping("/addMrTransfusion")
	public String addMrTransfusion() {
		
		//return syncDataService.addMrTransfusion();
		return null;
	}
	
	
	/**
	 * 同步his血型
	 * @param checkDate
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/syncBloodType")
	public String syncBloodType(String checkDate) {
		if(StringUtils.isEmpty(checkDate)) {
			checkDate = DateUtil.dateFormat("yyyy-MM-dd", new Date());
		}
		//return syncDataService.addMrTransfusion();
		return bloodTypeService.syncBloodType(checkDate);
	}
	
	
	
	/**
	 * 同步his床号
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/syncHisBed")
	public String syncHisBed(String startDate,String endDate) {
		
		if(StringUtils.isEmpty(startDate) || StringUtils.isEmpty(endDate)) {
			return "startDate和endDate不可为空!";
		}
		
		return syncHisDataService.syncHisInterfaceAdmInHosInfo(startDate, endDate);
	}
	
	
	/**
	 * 同步his床号
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/syncHisApplyReportQryPack")
	public String syncHisApplyReportQryPack(String startDate,String endDate) {
		
		if(StringUtils.isEmpty(startDate) || StringUtils.isEmpty(endDate)) {
			return "startDate和endDate不可为空!";
		}
		
		return syncHisDataService.syncHisApplyReportQryPack(startDate, endDate);
	}
	
	
	/**
	 * 同步床位信息
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/syncOpApplyBedInfo")
	public String syncHisBedInfo() {
		
		return syncHisDataService.syncOpApplyBedInfo();
	}
	
	
	
	

}
